package com.robot.admin.controller;

import com.robot.admin.pojo.Area;
import com.robot.admin.service.AreaService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * area控制器层
 *
 * @author lin
 */
@RestController
@CrossOrigin
@RequestMapping("/area")
public class AreaController {
    @Autowired
    private AreaService areaService;

    /**
     * 根据code查找area
     *
     * @param area
     * @return
     */
    @RequestMapping(value = "findByCode", method = RequestMethod.POST)
    public Result findByCode(@RequestBody Area area) {
        return new Result(StatusCode.SUCCESS_QUERY, areaService.findByCode(area.getCode()));
    }

    /**
     * 根据name查找area
     *
     * @param area
     * @return
     */
    @RequestMapping(value = "findByName", method = RequestMethod.POST)
    public Result findByName(@RequestBody Area area) {
        return new Result(StatusCode.SUCCESS_QUERY, areaService.findByName(area.getName()));
    }
}
